function request(ops){
    let {
        type="get",
        url,
        data={},
        success,
        error,
        timeout=1000,
        async=true
    } = ops;

    let str = "";
    for(let i in data){
        str += `${i}=${data[i]}&`;
    }

    if(type !== "post"){
        url = url + "?" + str + "__qft__=" + Date.now();
    }

    setTimeout(() => {
        error && error("timeout");
        success = null;
        error = null;
    }, timeout);

    let xhr;
    if(type !== "jsonp"){
        xhr = new XMLHttpRequest();
        xhr.open(type, url, async);
        xhr.onload = function(){
            if(xhr.status === 200){
                success && success(xhr.responseText);
                success = null;
                error = null;
            }else{
                error && error(xhr.status);
                success = null;
                error = null;
            }
        }
        if(type === "get"){
            xhr.send()
        }else{
            xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
            xhr.send(str.slice(0,str.length-1));
        }
        return;
    }

    let script = document.createElement("script");
    script.src = url;
    document.body.appendChild(script);
    window[data[data.cn]] = function(res){
        success && success(res);
        success = null;
        error = null;
    }
}